Fix #1504. Don't blow up on empty fingerprint files
authorGleb Kozyrev <gleb@gkoz.com>
Wed, 11 Nov 2015 23:56:21 +0000 (01:56 +0200)
committerGleb Kozyrev <gleb@gkoz.com>
Wed, 11 Nov 2015 23:56:21 +0000 (01:56 +0200)
src/cargo/ops/cargo_rustc/fingerprint.rs

index 945b42f23e404f9bf7d170aee986babbb738a1ff..885d3de820e111583e5bb1e4a06de577d835de11 100644 (file)
@@ -500,7 +500,9 @@ fn calculate_target_mtime(dep_info: &Path) -> CargoResult<Option<FileTime>> {
     let mut f = BufReader::new(fs_try!(File::open(dep_info)));
     // see comments in append_current_dir for where this cwd is manifested from.
     let mut cwd = Vec::new();
-    fs_try!(f.read_until(0, &mut cwd));
+    if fs_try!(f.read_until(0, &mut cwd)) == 0 {
+        return Ok(None)
+    }
     let cwd = try!(util::bytes2path(&cwd[..cwd.len()-1]));
     let line = match f.lines().next() {
         Some(Ok(line)) => line,